//# sourceURL=http://uMapApp/UI/Panel/TitleMenuPanel
define([
    "mhjs/mhjs"
    , "../TopMenu/TopMenu"
], function (
    mhjs
    , TopMenu
) {

    function TitleMenuPanel(option) {

        var _this = this;

        _this.ui = _this.ui || {};

        _this.ui.back = new TopMenu({"class": "back"});
        _this.ui.title = new mhjs.Div({"class": "title"});
        _this.ui.title.label = new mhjs.Div({"class": "label"});
        _this.ui.title.bg = new mhjs.Div({"class": "bg"});

        _this.ui.title
            .append(_this.ui.title.label)
            .append(_this.ui.title.bg);

        _this.isOpened = false;

        mhjs.Div.call(_this, option);
        _this.addClass("titleMenuPanel");

        _this
            .append(_this.ui.back)
            .append(_this.ui.title)
        ;


    }

    var _class = TitleMenuPanel;
    mhjs.Inherit(_class, mhjs.Div);


    Object.defineProperties(_class.prototype, {
        "title"     : {
            set: function (title) {
                var _this = this;
                _this._title = title;
                _this.ui.title.label.text(title);
            },
            get: function () {
                return this._title;
            }
        },
        "isShowBack": {
            set: function (isShowBack) {
                var _this = this;
                _this._isShowBack = isShowBack;
                _this.ui.back.toggle(isShowBack);
            },
            get: function () {
                return this._isShowBack;
            }
        },
        "open"      : {
            value: function (stopPropagation) {
                var _this = this;
                _this.isOpened = true;
                _this.addClass("open");
                stopPropagation !== false && _this.trigger("open");
            }
        },
        "close"     : {
            value: function (stopPropagation) {
                var _this = this;
                _this.isOpened = false;
                _this.removeClass("open");
                stopPropagation !== false && _this.trigger("close");
            }
        },
        "toggle"    : {
            value: function (stopPropagation) {
                var _this = this;
                if (_this.isOpened) {
                    _this.close(stopPropagation);
                } else {
                    _this.open(stopPropagation);
                }
            }
        }
    });

    return _class;

});